package com.example.demo.vo

import com.example.demo.dao.TJzrOrderDao
import com.example.demo.dbmodels.TJzrOrder
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiModelProperty
import me.liuwj.ktorm.dsl.QueryRowSet
import java.time.LocalDateTime

@ApiModel(description = "医嘱信息")
class OrderVo {
    @ApiModelProperty("病人ID")
    var ID: Long = -1

    @ApiModelProperty("病人ID")
    var PATIENT_ID: Int = -1

    @ApiModelProperty("住院次数")
    var SERIES: String = ""

    @ApiModelProperty("住院号")
    var ADMISSION_ID: String = ""

    @ApiModelProperty("医嘱组号(代表一组药，组号相同的药是一起使用的,相对于其他组来说,数据唯一")
    var GROUP_NO: Int? = -1

    @ApiModelProperty("医嘱号")
    var ORDER_NO: Int? = -1

    @ApiModelProperty("医嘱编码")
    var ORDER_CODE: String = ""

    @ApiModelProperty("医嘱名称")
    var ORDER_NAME: String = ""

    @ApiModelProperty("药品名称")
    var DRUG_NAME: String = ""

    @ApiModelProperty("病区代码")
    var WARD_CODE: String = ""

    @ApiModelProperty("科室代码")
    var DEPT_CODE: String = ""

    @ApiModelProperty("规格")
    var DRUG_SPEC: String = ""

    @ApiModelProperty(
        "频次代码(频次：\n" +
                "     *  ST、\n" +
                "     *  ONCE、\n" +
                "     *  BID、\n" +
                "     *  QD等\n" +
                "     *  )"
    )
    var FREQUENCY_CODE: String = ""

    @ApiModelProperty("频次名称")
    var FREQUENCY_NAME: String = ""

    @ApiModelProperty("首日次数")
    var TODAY_TIMES: Int? = -1

    @ApiModelProperty("剂量")
    var DOSAGE: String = ""

    @ApiModelProperty("剂量单位")
    var DOSAGE_UNIT: String = ""

    @ApiModelProperty("给药方式代码")
    var SUPPLY_CODE: String = ""

    @ApiModelProperty("给药方式")
    var SUPPLY_NAME: String = ""

    @ApiModelProperty("医嘱状态")
    var ORDER_STATUS: String = ""

    @ApiModelProperty("医嘱类别")
    var ORDER_CLASS: String = ""

    @ApiModelProperty(
        "     *  医嘱类别名(医嘱类别：\n" +
                "     *  a 西药 、中成药\n" +
                "     *  b 中药\n" +
                "     *  c 检验\n" +
                "     *  d 检查\n" +
                "     *  e 治疗\n" +
                "     *  f 手术\n" +
                "     *  g 麻醉\n" +
                "     *  h 护理\n" +
                "     *  i 膳食\n" +
                "     *  j 输血\n" +
                "     *  z 其他"
    )
    var ORDER_CLASS_NAME: String = ""

    @ApiModelProperty("临时标记")
    var LONG_ONCE_FLAG: String = ""

    @ApiModelProperty("是否高危药品")
    var HIGH_RISK: String = ""

    @ApiModelProperty("是否需要先做皮试")
    var SKIN_TEST: String = ""

    @ApiModelProperty("自备药标志")
    var PROVIDE_BY_SELF: String = ""

    @ApiModelProperty(
        "   *  副药标志(是否副药,\n" +
                "     *  0表示主药,\n" +
                "     *  1表示副药\n" +
                "     *  )"
    )
    var IS_AUX: String = ""

    @ApiModelProperty(
        "     *  加急标志(是否加急,\n" +
                "     *  0表示普通,\n" +
                "     *  1表示加急\n" +
                "     *  )"
    )
    var IS_URGENT: String = ""

    @ApiModelProperty("开始时间")
    var START_TIME: LocalDateTime? = null

    @ApiModelProperty("开嘱时间")
    var ENTER_TIME: LocalDateTime? = null

    @ApiModelProperty("开立医生代码")
    var DOCTOR_CODE: String = ""

    @ApiModelProperty("开嘱医生姓名")
    var DOCTOR_NAME: String = ""

    @ApiModelProperty("停止时间")
    var STOP_TIME: LocalDateTime? = null

    @ApiModelProperty("停止医生代码")
    var STOP_DOCTOR_CODE: String = ""

    @ApiModelProperty("停止医生姓名")
    var STOP_DOCTOR_NAME: String = ""

    @ApiModelProperty("嘱托")
    var EXHORTATION: String = ""

    @ApiModelProperty("备注")
    var REMARK: String = ""

    fun getVo(queue: QueryRowSet): OrderVo {
        queue.let {
            val data = OrderVo()
            data.ADMISSION_ID = it[TJzrOrderDao.ADMISSION_ID].toString()
            data.DEPT_CODE = it[TJzrOrderDao.DEPT_CODE].toString()
            data.DOCTOR_CODE = it[TJzrOrderDao.DOCTOR_CODE].toString()
            data.DOCTOR_NAME = it[TJzrOrderDao.DOCTOR_NAME].toString()
            data.DOSAGE = it[TJzrOrderDao.DOSAGE].toString()
            data.DOSAGE_UNIT = it[TJzrOrderDao.DOSAGE_UNIT].toString()
            data.DRUG_NAME = it[TJzrOrderDao.DRUG_NAME].toString()
            data.DRUG_SPEC = it[TJzrOrderDao.DRUG_SPEC].toString()
            data.ENTER_TIME = it[TJzrOrderDao.ENTER_TIME]
            data.EXHORTATION = it[TJzrOrderDao.EXHORTATION].toString()
            data.FREQUENCY_CODE = it[TJzrOrderDao.FREQUENCY_CODE].toString()
            data.FREQUENCY_NAME = it[TJzrOrderDao.FREQUENCY_NAME].toString()
            data.GROUP_NO = it[TJzrOrderDao.FREQUENCY_NAME]?.toInt()
            data.HIGH_RISK = it[TJzrOrderDao.HIGH_RISK].toString()
            data.ID = it[TJzrOrderDao.ID]!!
            data.IS_AUX = it[TJzrOrderDao.IS_AUX].toString()
            data.IS_URGENT = it[TJzrOrderDao.IS_URGENT].toString()
            data.LONG_ONCE_FLAG = it[TJzrOrderDao.LONG_ONCE_FLAG].toString()
            data.ORDER_CLASS = it[TJzrOrderDao.ORDER_CLASS].toString()
            data.ORDER_CLASS_NAME = it[TJzrOrderDao.ORDER_CLASS_NAME].toString()
            data.ORDER_CODE = it[TJzrOrderDao.ORDER_CODE].toString()
            data.ORDER_NAME = it[TJzrOrderDao.ORDER_NAME].toString()
            data.ORDER_NO = it[TJzrOrderDao.ORDER_NO]?.toInt()
            data.ORDER_STATUS = it[TJzrOrderDao.ORDER_STATUS].toString()
            data.PATIENT_ID = it[TJzrOrderDao.PATIENT_ID]?.toInt()!!
            data.PROVIDE_BY_SELF = it[TJzrOrderDao.PROVIDE_BY_SELF].toString()
            data.REMARK = it[TJzrOrderDao.REMARK].toString()
            data.SERIES = it[TJzrOrderDao.SERIES].toString()
            data.SKIN_TEST = it[TJzrOrderDao.SKIN_TEST].toString()
            data.START_TIME = it[TJzrOrderDao.START_TIME]
            data.STOP_DOCTOR_CODE = it[TJzrOrderDao.STOP_DOCTOR_CODE].toString()
            data.STOP_DOCTOR_NAME = it[TJzrOrderDao.STOP_DOCTOR_NAME].toString()
            data.STOP_TIME = it[TJzrOrderDao.STOP_TIME]
            data.SUPPLY_CODE = it[TJzrOrderDao.SUPPLY_CODE].toString()
            data.SUPPLY_NAME = it[TJzrOrderDao.SUPPLY_NAME].toString()
            data.TODAY_TIMES = it[TJzrOrderDao.TODAY_TIMES]
            data.WARD_CODE = it[TJzrOrderDao.WARD_CODE].toString()
            return data
        }
    }

    fun getVo(table: TJzrOrder): OrderVo {
        table.let {
            val data = OrderVo()
            data.ADMISSION_ID = it.ADMISSION_ID
            data.DEPT_CODE = it.DEPT_CODE
            data.DOCTOR_CODE = it.DOCTOR_CODE
            data.DOCTOR_NAME = it.DOCTOR_NAME
            data.DOSAGE = it.DOSAGE
            data.DOSAGE_UNIT = it.DOSAGE_UNIT
            data.DRUG_NAME = it.DRUG_NAME
            data.DRUG_SPEC = it.DRUG_SPEC
            data.ENTER_TIME = it.ENTER_TIME
            data.EXHORTATION = it.EXHORTATION
            data.FREQUENCY_CODE = it.FREQUENCY_CODE
            data.FREQUENCY_NAME = it.FREQUENCY_NAME
            data.GROUP_NO = it.GROUP_NO
            data.HIGH_RISK = it.HIGH_RISK
            data.ID = it.ID
            data.IS_AUX = it.IS_AUX
            data.IS_URGENT = it.IS_URGENT
            data.LONG_ONCE_FLAG = it.LONG_ONCE_FLAG
            data.ORDER_CLASS = it.ORDER_CLASS
            data.ORDER_CLASS_NAME = it.ORDER_CLASS_NAME
            data.ORDER_CODE = it.ORDER_CODE
            data.ORDER_NAME = it.ORDER_NAME
            data.ORDER_NO = it.ORDER_NO
            data.ORDER_STATUS = it.ORDER_STATUS
            data.PATIENT_ID = it.PATIENT_ID
            data.PROVIDE_BY_SELF = it.PROVIDE_BY_SELF
            data.REMARK = it.REMARK
            data.SERIES = it.SERIES
            data.SKIN_TEST = it.SKIN_TEST
            data.START_TIME = it.START_TIME
            data.STOP_DOCTOR_CODE = it.STOP_DOCTOR_CODE
            data.STOP_DOCTOR_NAME = it.STOP_DOCTOR_NAME
            data.STOP_TIME = it.STOP_TIME
            data.SUPPLY_CODE = it.SUPPLY_CODE
            data.SUPPLY_NAME = it.SUPPLY_NAME
            data.TODAY_TIMES = it.TODAY_TIMES
            data.WARD_CODE = it.WARD_CODE
            return data
        }
    }

    fun getListVo(table: List<TJzrOrder>): List<OrderVo> {
        table.let {
            val orderVos = mutableListOf<OrderVo>()
            for (item in table) {
                val data = OrderVo()
                data.ADMISSION_ID = item.ADMISSION_ID
                data.DEPT_CODE = item.DEPT_CODE
                data.DOCTOR_CODE = item.DOCTOR_CODE
                data.DOCTOR_NAME = item.DOCTOR_NAME
                data.DOSAGE = item.DOSAGE
                data.DOSAGE_UNIT = item.DOSAGE_UNIT
                data.DRUG_NAME = item.DRUG_NAME
                data.DRUG_SPEC = item.DRUG_SPEC
                data.ENTER_TIME = item.ENTER_TIME
                data.EXHORTATION = item.EXHORTATION
                data.FREQUENCY_CODE = item.FREQUENCY_CODE
                data.FREQUENCY_NAME = item.FREQUENCY_NAME
                data.GROUP_NO = item.GROUP_NO
                data.HIGH_RISK = item.HIGH_RISK
                data.ID = item.ID
                data.IS_AUX = item.IS_AUX
                data.IS_URGENT = item.IS_URGENT
                data.LONG_ONCE_FLAG = item.LONG_ONCE_FLAG
                data.ORDER_CLASS = item.ORDER_CLASS
                data.ORDER_CLASS_NAME = item.ORDER_CLASS_NAME
                data.ORDER_CODE = item.ORDER_CODE
                data.ORDER_NAME = item.ORDER_NAME
                data.ORDER_NO = item.ORDER_NO
                data.ORDER_STATUS = item.ORDER_STATUS
                data.PATIENT_ID = item.PATIENT_ID
                data.PROVIDE_BY_SELF = item.PROVIDE_BY_SELF
                data.REMARK = item.REMARK
                data.SERIES = item.SERIES
                data.SKIN_TEST = item.SKIN_TEST
                data.START_TIME = item.START_TIME
                data.STOP_DOCTOR_CODE = item.STOP_DOCTOR_CODE
                data.STOP_DOCTOR_NAME = item.STOP_DOCTOR_NAME
                data.STOP_TIME = item.STOP_TIME
                data.SUPPLY_CODE = item.SUPPLY_CODE
                data.SUPPLY_NAME = item.SUPPLY_NAME
                data.TODAY_TIMES = item.TODAY_TIMES
                data.WARD_CODE = item.WARD_CODE
                orderVos.add(data)
            }
            return orderVos
        }

    }

}